package cn.lzj;

import cn.lzj.listener.indexStartEvent;
import cn.lzj.listener.indexStartEventListener;
import cn.lzj.service.base.IndexService;
import cn.lzj.service.base.impl.indexServiceImpl;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;


import java.util.Properties;

import static com.google.code.kaptcha.Constants.*;

@SpringBootApplication
@MapperScan(basePackages = "cn.lzj.mapper")
//@MapperScan("cn.lzj")
@EnableTransactionManagement
public class Pro02FountionModuleApplication {

    public static void main(String[] args) {

        ConfigurableApplicationContext run = SpringApplication.run(Pro02FountionModuleApplication.class, args);

        String[] str=run.getBeanDefinitionNames();
        //在启动类中，添加自定义监听器
        run.addApplicationListener(new indexStartEventListener());
        run.publishEvent(new indexStartEvent(new Object()));

    }

    @Bean
    public DefaultKaptcha getDefaultKaptcha(){
        com.google.code.kaptcha.impl.DefaultKaptcha defaultKaptcha = new com.google.code.kaptcha.impl.DefaultKaptcha();
        Properties properties = new Properties();
        properties.setProperty("kaptcha.border", "yes");
        properties.setProperty("kaptcha.border.color", "105,179,90");
        properties.setProperty("kaptcha.textproducer.font.color", "blue");
        properties.setProperty("kaptcha.image.width", "110");
        properties.setProperty("kaptcha.image.height", "40");
        properties.setProperty("kaptcha.textproducer.font.size", "30");
        properties.setProperty("kaptcha.session.key", "code");
        properties.setProperty("kaptcha.textproducer.char.length", "4");
        properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
        Config config = new Config(properties);
        defaultKaptcha.setConfig(config);

        return defaultKaptcha;
    }


}
